<%@ page language="java" contentType="text/html;charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>${p.appName} 管理后台</title>
<link rel="stylesheet" href="/css/smoothness/jquery-ui-1.8.18.custom.css"></link>
<link rel="stylesheet" href="/css/admin.css"></link>
<script type="text/javascript" src="/js/jquery-1.7.1.min.js"></script>
<script type="text/javascript" src="/js/ui/jquery.ui.core.js"></script>
<script type="text/javascript" src="/js/ui/jquery.ui.widget.js"></script>
<script type="text/javascript" src="/js/ui/jquery.ui.button.js"></script>
<script type="text/javascript" src="/js/ui/jquery.ui.position.js"></script>
<script type="text/javascript" src="/js/ui/jquery.ui.autocomplete.js"></script>
<script type="text/javascript">
	(function( $ ) {
		$.widget( "ui.combobox", {
			_create: function() {
				var self = this,
					select = this.element.hide(),
					selected = select.children( ":selected" ),
					value = selected.val() ? selected.text() : "";
				var input = this.input = $( "<input>" )
					.insertAfter( select )
					.val( value )
					.autocomplete({
						delay: 0,
						minLength: 0,
						source: function( request, response ) {
							var matcher = new RegExp( $.ui.autocomplete.escapeRegex(request.term), "i" );
							response( select.children( "option" ).map(function() {
								var text = $( this ).text();
								if ( this.value && ( !request.term || matcher.test(text) ) )
									return {
										label: text.replace(
											new RegExp(
												"(?![^&;]+;)(?!<[^<>]*)(" +
												$.ui.autocomplete.escapeRegex(request.term) +
												")(?![^<>]*>)(?![^&;]+;)", "gi"
											), "<strong>$1</strong>" ),
										value: text,
										option: this
									};
							}) );
						},
						select: function( event, ui ) {
							ui.item.option.selected = true;
							self._trigger( "selected", event, {
								item: ui.item.option
							});
						},
						change: function( event, ui ) {
							if ( !ui.item ) {
								var matcher = new RegExp( "^" + $.ui.autocomplete.escapeRegex( $(this).val() ) + "$", "i" ),
									valid = false;
								select.children( "option" ).each(function() {
									if ( $( this ).text().match( matcher ) ) {
										this.selected = valid = true;
										return false;
									}
								});
								if ( !valid ) {
									// remove invalid value, as it didn't match anything
									$( this ).val( "" );
									select.val( "" );
									input.data( "autocomplete" ).term = "";
									return false;
								}
							}
						}
					})
					.addClass( "ui-widget ui-widget-content ui-corner-left" );

				input.data( "autocomplete" )._renderItem = function( ul, item ) {
					return $( "<li></li>" )
						.data( "item.autocomplete", item )
						.append( "<a>" + item.label + "</a>" )
						.appendTo( ul );
				};

				this.button = $( "<button type='button'>&nbsp;</button>" )
					.attr( "tabIndex", -1 )
					.attr( "title", "Show All Items" )
					.insertAfter( input )
					.button({
						icons: {
							primary: "ui-icon-triangle-1-s"
						},
						text: false
					})
					.removeClass( "ui-corner-all" )
					.addClass( "ui-corner-right ui-button-icon" )
					.click(function() {
						// close if already visible
						if ( input.autocomplete( "widget" ).is( ":visible" ) ) {
							input.autocomplete( "close" );
							return;
						}

						// work around a bug (likely same cause as #5265)
						$( this ).blur();

						// pass empty string as value to search for, displaying all results
						input.autocomplete( "search", "" );
						input.focus();
					});
			},

			destroy: function() {
				this.input.remove();
				this.button.remove();
				this.element.show();
				$.Widget.prototype.destroy.call( this );
			}
		});
	})( jQuery );

	$(function() {
		$( "#itemid" ).combobox();
	});
</script>
</head>
<body>


<p style="width:500px; margin: 20px  auto 0  126px; color:#ddd"> --------- or --------- </p>


<div id="advanced" style="width:350px; margin: 10px auto 0 0; border: solid 0px #eee; text-align:right;">

<h4 style=" margin:10px auto 0 auto; font-size:14px; text-align:center;">发送自定义GM指令</h4>
	
	<c:if test="${errorMessageAdvanced != null}">
		<div class="errorMesage" style="margin:10px auto 0 auto;">
			${errorMessageAdvanced}
		</div>
	</c:if>
	<c:if test="${resultAdvanced != null}">
		<div class="result" style="margin:10px auto 0 auto;">
			<p style="margin:5px; text-align:center; "> 运行结果: ${resultAdvanced} <span style="color:#aaa; font-size:9px; font-style: italic;">(用时:${useTimes/1000}秒)</span></div>
		</div>
	</c:if>
		
	<form action="sendcmd.dragon">
	<table class="infoTable" cellpadding="2px" cellspacing="2px" >
		<tbody>
			<tr><td class="tdtitle" style="width:20px;">执行次数:</td>
				<td class="tddata" ><input id="num" name="num" type="text" value="${num} "/></td></tr>
			<tr><td class="tdtitle" style="width:20px;">命令:</td>
				<td class="tddata" ><textarea id="customCmd" name="customCmd" rows="5" cols="50">${customCmd}</textarea></td></tr>
			<tr><td class="" colspan="2" style="text-align:center;">  
					<input id="act" name="act" value="advanced" type="hidden"></input>
					<input type="submit" value="&nbsp;&nbsp;&nbsp;&nbsp;执&nbsp;&nbsp;行&nbsp;&nbsp;&nbsp;&nbsp;"></input>
					<input  id="user" name="user" type="hidden" value="dragoncity_admin_20131101"/>
				</td>
			</tr>	
		</tbody>
	</table>
	</form>
</body>
</html>
